class Solution(object):
    def plusOne(self, digits):
        for i in reversed(range(len(digits))):
            if digits[i] < 9:
                digits[i] += 1
                return digits
            digits[i] = 0
        digits.insert(0, 1)
        return digits


if __name__ == '__main__':
    s = Solution()
    r = s.plusOne([9, 9, 9, 9])
    print(r)
